package cn.cdeden.aiqa.mapper;

import cn.cdeden.aiqa.domain.WikiModel;
import cn.cdeden.aiqa.domain.vo.WikiModelVo;
import cn.cdeden.common.mybatis.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * 模型管理Mapper接口
 *
 * @author Nick
 * @date 2025-02-13
 */
public interface WikiModelMapper extends BaseMapperPlus<WikiModel, WikiModelVo> {

    @Select({
        "<script>",
        "SELECT * FROM wiki_model",
        "WHERE 1=1",
        "<if test='roleIds != null and roleIds.size() > 0'>",
        "AND (",
        "<foreach collection='roleIds' item='roleId' separator=' OR '>",
        "FIND_IN_SET(#{roleId}, allowed_roles) > 0",
        "</foreach>",
        ")",
        "</if>",
        "ORDER BY sort ASC",
        "</script>"
    })
    List<WikiModelVo> selectByRoleIds(@Param("roleIds")Set<Long> roleIds);
}
